1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module adw.Squeezer;
26 
27 private import adw.SqueezerPage;
28 private import adw.c.functions;
29 public  import adw.c.types;
30 private import glib.ConstructionException;
31 private import gobject.ObjectG;
32 private import gtk.AccessibleIF;
33 private import gtk.AccessibleT;
34 private import gtk.BuildableIF;
35 private import gtk.BuildableT;
36 private import gtk.ConstraintTargetIF;
37 private import gtk.ConstraintTargetT;
38 private import gtk.OrientableIF;
39 private import gtk.OrientableT;
40 private import gtk.SelectionModelIF;
41 private import gtk.Widget;
42 
43 
44 /**
45  * A best fit container.
46  * 
47  * <picture>
48  * <source srcset="squeezer-wide-dark.png" media="(prefers-color-scheme: dark)">
49  * <img src="squeezer-wide.png" alt="squeezer-wide">
50  * </picture>
51  * <picture>
52  * <source srcset="squeezer-narrow-dark.png" media="(prefers-color-scheme: dark)">
53  * <img src="squeezer-narrow.png" alt="squeezer-narrow">
54  * </picture>
55  * 
56  * The `AdwSqueezer` widget is a container which only shows the first of its
57  * children that fits in the available size. It is convenient to offer different
58  * widgets to represent the same data with different levels of detail, making
59  * the widget seem to squeeze itself to fit in the available space.
60  * 
61  * Transitions between children can be animated as fades. This can be controlled
62  * with [property@Squeezer:transition-type].
63  * 
64  * ## CSS nodes
65  * 
66  * `AdwSqueezer` has a single CSS node with name `squeezer`.
67  *
68  * Since: 1.0
69  */
70 public class Squeezer : Widget, OrientableIF
71 {
72 	/** the main Gtk struct */
73 	protected AdwSqueezer* adwSqueezer;
74 
75 	/** Get the main Gtk struct */
76 	public AdwSqueezer* getSqueezerStruct(bool transferOwnership = false)
77 	{
78 		if (transferOwnership)
79 			ownedRef = false;
80 		return adwSqueezer;
81 	}
82 
83 	/** the main Gtk struct as a void* */
84 	protected override void* getStruct()
85 	{
86 		return cast(void*)adwSqueezer;
87 	}
88 
89 	/**
90 	 * Sets our main struct and passes it to the parent class.
91 	 */
92 	public this (AdwSqueezer* adwSqueezer, bool ownedRef = false)
93 	{
94 		this.adwSqueezer = adwSqueezer;
95 		super(cast(GtkWidget*)adwSqueezer, ownedRef);
96 	}
97 
98 	// add the Orientable capabilities
99 	mixin OrientableT!(AdwSqueezer);
100 
101 
102 	/** */
103 	public static GType getType()
104 	{
105 		return adw_squeezer_get_type();
106 	}
107 
108 	/**
109 	 * Creates a new `AdwSqueezer`.
110 	 *
111 	 * Returns: the newly created `AdwSqueezer`
112 	 *
113 	 * Since: 1.0
114 	 *
115 	 * Throws: ConstructionException GTK+ fails to create the object.
116 	 */
117 	public this()
118 	{
119 		auto __p = adw_squeezer_new();
120 
121 		if(__p is null)
122 		{
123 			throw new ConstructionException("null returned by new");
124 		}
125 
126 		this(cast(AdwSqueezer*) __p);
127 	}
128 
129 	/**
130 	 * Adds a child to @self.
131 	 *
132 	 * Params:
133 	 *     child = the widget to add
134 	 *
135 	 * Returns: the [class@SqueezerPage] for @child
136 	 *
137 	 * Since: 1.0
138 	 */
139 	public SqueezerPage add(Widget child)
140 	{
141 		auto __p = adw_squeezer_add(adwSqueezer, (child is null) ? null : child.getWidgetStruct());
142 
143 		if(__p is null)
144 		{
145 			return null;
146 		}
147 
148 		return ObjectG.getDObject!(SqueezerPage)(cast(AdwSqueezerPage*) __p);
149 	}
150 
151 	/**
152 	 * Gets whether to allow squeezing beyond the last child's minimum size.
153 	 *
154 	 * Returns: whether @self allows squeezing beyond the last child
155 	 *
156 	 * Since: 1.0
157 	 */
158 	public bool getAllowNone()
159 	{
160 		return adw_squeezer_get_allow_none(adwSqueezer) != 0;
161 	}
162 
163 	/**
164 	 * Gets whether all children have the same size for the opposite orientation.
165 	 *
166 	 * Returns: whether @self is homogeneous
167 	 *
168 	 * Since: 1.0
169 	 */
170 	public bool getHomogeneous()
171 	{
172 		return adw_squeezer_get_homogeneous(adwSqueezer) != 0;
173 	}
174 
175 	/**
176 	 * Gets whether @self interpolates its size when changing the visible child.
177 	 *
178 	 * Returns: whether the size is interpolated
179 	 *
180 	 * Since: 1.0
181 	 */
182 	public bool getInterpolateSize()
183 	{
184 		return adw_squeezer_get_interpolate_size(adwSqueezer) != 0;
185 	}
186 
187 	/**
188 	 * Returns the [class@SqueezerPage] object for @child.
189 	 *
190 	 * Params:
191 	 *     child = a child of @self
192 	 *
193 	 * Returns: the page object for @child
194 	 *
195 	 * Since: 1.0
196 	 */
197 	public SqueezerPage getPage(Widget child)
198 	{
199 		auto __p = adw_squeezer_get_page(adwSqueezer, (child is null) ? null : child.getWidgetStruct());
200 
201 		if(__p is null)
202 		{
203 			return null;
204 		}
205 
206 		return ObjectG.getDObject!(SqueezerPage)(cast(AdwSqueezerPage*) __p);
207 	}
208 
209 	/**
210 	 * Returns a [iface@Gio.ListModel] that contains the pages of @self.
211 	 *
212 	 * This can be used to keep an up-to-date view. The model also implements
213 	 * [iface@Gtk.SelectionModel] and can be used to track the visible page.
214 	 *
215 	 * Returns: a `GtkSelectionModel` for the squeezer's children
216 	 *
217 	 * Since: 1.0
218 	 */
219 	public SelectionModelIF getPages()
220 	{
221 		auto __p = adw_squeezer_get_pages(adwSqueezer);
222 
223 		if(__p is null)
224 		{
225 			return null;
226 		}
227 
228 		return ObjectG.getDObject!(SelectionModelIF)(cast(GtkSelectionModel*) __p, true);
229 	}
230 
231 	/**
232 	 * Gets the fold threshold policy for @self.
233 	 *
234 	 * Since: 1.0
235 	 */
236 	public AdwFoldThresholdPolicy getSwitchThresholdPolicy()
237 	{
238 		return adw_squeezer_get_switch_threshold_policy(adwSqueezer);
239 	}
240 
241 	/**
242 	 * Gets the transition animation duration for @self.
243 	 *
244 	 * Returns: the transition duration, in milliseconds
245 	 *
246 	 * Since: 1.0
247 	 */
248 	public uint getTransitionDuration()
249 	{
250 		return adw_squeezer_get_transition_duration(adwSqueezer);
251 	}
252 
253 	/**
254 	 * Gets whether a transition is currently running for @self.
255 	 *
256 	 * Returns: whether a transition is currently running
257 	 *
258 	 * Since: 1.0
259 	 */
260 	public bool getTransitionRunning()
261 	{
262 		return adw_squeezer_get_transition_running(adwSqueezer) != 0;
263 	}
264 
265 	/**
266 	 * Gets the type of animation used for transitions between children in @self.
267 	 *
268 	 * Returns: the current transition type of @self
269 	 *
270 	 * Since: 1.0
271 	 */
272 	public AdwSqueezerTransitionType getTransitionType()
273 	{
274 		return adw_squeezer_get_transition_type(adwSqueezer);
275 	}
276 
277 	/**
278 	 * Gets the currently visible child of @self.
279 	 *
280 	 * Returns: the visible child
281 	 *
282 	 * Since: 1.0
283 	 */
284 	public Widget getVisibleChild()
285 	{
286 		auto __p = adw_squeezer_get_visible_child(adwSqueezer);
287 
288 		if(__p is null)
289 		{
290 			return null;
291 		}
292 
293 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
294 	}
295 
296 	/**
297 	 * Gets the horizontal alignment, from 0 (start) to 1 (end).
298 	 *
299 	 * Returns: the alignment value
300 	 *
301 	 * Since: 1.0
302 	 */
303 	public float getXalign()
304 	{
305 		return adw_squeezer_get_xalign(adwSqueezer);
306 	}
307 
308 	/**
309 	 * Gets the vertical alignment, from 0 (top) to 1 (bottom).
310 	 *
311 	 * Returns: the alignment value
312 	 *
313 	 * Since: 1.0
314 	 */
315 	public float getYalign()
316 	{
317 		return adw_squeezer_get_yalign(adwSqueezer);
318 	}
319 
320 	/**
321 	 * Removes a child widget from @self.
322 	 *
323 	 * Params:
324 	 *     child = the child to remove
325 	 *
326 	 * Since: 1.0
327 	 */
328 	public void remove(Widget child)
329 	{
330 		adw_squeezer_remove(adwSqueezer, (child is null) ? null : child.getWidgetStruct());
331 	}
332 
333 	/**
334 	 * Sets whether to allow squeezing beyond the last child's minimum size.
335 	 *
336 	 * Params:
337 	 *     allowNone = whether @self allows squeezing beyond the last child
338 	 *
339 	 * Since: 1.0
340 	 */
341 	public void setAllowNone(bool allowNone)
342 	{
343 		adw_squeezer_set_allow_none(adwSqueezer, allowNone);
344 	}
345 
346 	/**
347 	 * Sets whether all children have the same size for the opposite orientation.
348 	 *
349 	 * Params:
350 	 *     homogeneous = whether @self is homogeneous
351 	 *
352 	 * Since: 1.0
353 	 */
354 	public void setHomogeneous(bool homogeneous)
355 	{
356 		adw_squeezer_set_homogeneous(adwSqueezer, homogeneous);
357 	}
358 
359 	/**
360 	 * Sets whether @self interpolates its size when changing the visible child.
361 	 *
362 	 * Params:
363 	 *     interpolateSize = whether to interpolate the size
364 	 *
365 	 * Since: 1.0
366 	 */
367 	public void setInterpolateSize(bool interpolateSize)
368 	{
369 		adw_squeezer_set_interpolate_size(adwSqueezer, interpolateSize);
370 	}
371 
372 	/**
373 	 * Sets the fold threshold policy for @self.
374 	 *
375 	 * Params:
376 	 *     policy = the policy to use
377 	 *
378 	 * Since: 1.0
379 	 */
380 	public void setSwitchThresholdPolicy(AdwFoldThresholdPolicy policy)
381 	{
382 		adw_squeezer_set_switch_threshold_policy(adwSqueezer, policy);
383 	}
384 
385 	/**
386 	 * Sets the transition animation duration for @self.
387 	 *
388 	 * Params:
389 	 *     duration = the new duration, in milliseconds
390 	 *
391 	 * Since: 1.0
392 	 */
393 	public void setTransitionDuration(uint duration)
394 	{
395 		adw_squeezer_set_transition_duration(adwSqueezer, duration);
396 	}
397 
398 	/**
399 	 * Sets the type of animation used for transitions between children in @self.
400 	 *
401 	 * Params:
402 	 *     transition = the new transition type
403 	 *
404 	 * Since: 1.0
405 	 */
406 	public void setTransitionType(AdwSqueezerTransitionType transition)
407 	{
408 		adw_squeezer_set_transition_type(adwSqueezer, transition);
409 	}
410 
411 	/**
412 	 * Sets the horizontal alignment, from 0 (start) to 1 (end).
413 	 *
414 	 * Params:
415 	 *     xalign = the new alignment value
416 	 *
417 	 * Since: 1.0
418 	 */
419 	public void setXalign(float xalign)
420 	{
421 		adw_squeezer_set_xalign(adwSqueezer, xalign);
422 	}
423 
424 	/**
425 	 * Sets the vertical alignment, from 0 (top) to 1 (bottom).
426 	 *
427 	 * Params:
428 	 *     yalign = the new alignment value
429 	 *
430 	 * Since: 1.0
431 	 */
432 	public void setYalign(float yalign)
433 	{
434 		adw_squeezer_set_yalign(adwSqueezer, yalign);
435 	}
436 }